package Sagittarius.VO
{
	import flash.utils.describeType;
	import com.pblabs.engine.debug.Logger;
	
	/**************************************************************************
	 * ...
	 * @author Aqua
	 *************************************************************************/
	public class BasicVO
	{
		/**************************************************************************
		 * function				BasicVO
		 * description			constructor
		 * @param	values		an object that contains default values for all member variables
		 *************************************************************************/
		public function BasicVO(values:Object):void
		{
			initialize(values);
		}
		
		/**************************************************************************
		 * function				initialize
		 * description			initialize all member variables
		 * @param	values		an object that contains default values for all member variables
		 *************************************************************************/
		protected function initialize(values:Object):void
		{
			var xml:XML;
			var xmllist:XMLList;
			var item:XML;
			var memVarName:String;
			
			xml = describeType(this);
			xmllist = xml..accessor;
			
			for each(item in xmllist)
			{
				memVarName = item.@name.toString();
				
				if (null == values[memVarName])
				{
					Logger.print(this, "Default value for member variable [" + memVarName + "] hasn't been found in parameters!");
				}
				else
				{
					this[memVarName] = values[memVarName];
				}
			}
		}
	}
	
}